﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApplication.Controllers
{
    public class TempController : Controller
    {
        Models.DataClasses1DataContext d = new Models.DataClasses1DataContext();
        // GET: Temp
        public ActionResult Index()
        {
            return View(d.Temp.OrderBy(t=>t.dateTime));
        }



        // GET: Temp/Delete/5
        public ActionResult Delete(int id)
        {

            d.Temp.DeleteAllOnSubmit(d.Temp.Where(t => t.id == id));
            d.SubmitChanges();
            return View("Index");
        }

        public ActionResult Clear(int id)
        {

            d.Temp.DeleteAllOnSubmit(d.Temp.Where(t => t.idWork == id));
            d.SubmitChanges();
            return RedirectToAction("Edit/"+id,"Work");
        }
        public FileContentResult GetFile(int id)
        {
            var dat = d.Temp.First(t => t.id == id);
            return File(dat.data.ToArray(), "application/zip", dat.id + ".zip");
        }

    }
}
